﻿/*
 * @Author Wujiajun
 * @Data 2021/2/20
 * @Description
 * 场景C#与Lua的调用，绑定
 * 场景激活，未激活，进入，离开
 * 
 */

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SceneLogicBehaviour : LuaBehaviour
{
    public string SceneName; //对公共变量大写

    private Action m_SceneActive;
    private Action m_SceneInActive;
    private Action m_SceneOnEnter;
    private Action m_SceneOnQuit;

    public override void Init(string luaName)
    {
        base.Init(luaName);
        m_ScriptEnv.Get("OnSceneActive",out m_SceneActive);
        m_ScriptEnv.Get("OnSceneInActive", out m_SceneInActive);
        m_ScriptEnv.Get("OnSceneEnter", out m_SceneOnEnter);
        m_ScriptEnv.Get("OnSceneQuit", out m_SceneOnQuit);
    }

    public void OnSceneActive()
    {
        m_SceneActive?.Invoke();
    }
    public void OnSceneInActive()
    {
        m_SceneInActive?.Invoke();
    }
    public void OnSceneEnter()
    {
        m_SceneOnEnter?.Invoke();
    }
    public void OnSceneQuit()
    {
        m_SceneOnQuit?.Invoke();
    }

    protected override void LuaClear()
    {
        base.LuaClear();
        m_SceneActive = null;
        m_SceneInActive = null;
        m_SceneOnEnter = null;
        m_SceneOnQuit = null;
    }
}
